Chiffre		[0-9]
Entier		{Chiffre}+
Lettre		[a-zA-Z]
LC			({Lettre}|{Chiffre})
Delim		[ \n\t\r]
Symbole		[+\-*/();,{}:"."]
Guill		"\""
Star		"*"
NotStar		[^*]
NotStarPar	[^*/]
InComment	({NotStar}|({Star}+{NotStarPar}+))*{Star}*
Comment		"/*"{InComment}"*/"
BS			\\.
PasBSG		[^\\"\n]
IntString	({BS}|{PasBSG})*


%{
#include "main.h"
#include "Projet.h"

YYSTYPE yylval;
extern int yylineno;


int TesteMotClef(char *s) {
	if (! strcasecmp(s, "class")) return CLASS;
	if (! strcasecmp(s, "extends")) return EXTENDS;
	if (! strcasecmp(s, "val")) return VAL;
	if (! strcasecmp(s, "var")) return VAR;
	if (! strcasecmp(s, "new")) return NW;
	if (! strcasecmp(s, "def")) return DEF;
	if (! strcasecmp(s, "returns")) return RETURNS;
	if (! strcasecmp(s, "is")) return IS;
	if (! strcasecmp(s, "override")) return OVERRIDE;
	if (! strcasecmp(s, "if")) return IF;
	if (! strcasecmp(s, "then")) return THEN;
	if (! strcasecmp(s, "else")) return ELSE;
	if (! strcasecmp(s, "self")) return SELF;
	if (! strcasecmp(s, "super")) return SUPER;

	yylval.S = strdup(yytext); return ID;
}

%}


%%
{Entier}			{ yylval.E = atoi(yytext); return CSTE; }
{Lettre}{LC}*		{ return TesteMotClef(yytext); }
{Symbole}			{ return yytext[0]; }
:=					{ yylval.C = Aff; return AFF; }
=					{ yylval.C = EQ; return RELOP; }
\<>					{ yylval.C = NEQ; return RELOP; }
\<=					{ yylval.C = LE; return RELOP; }
>=					{ yylval.C = GE; return RELOP; }
>					{ yylval.C = GT; return RELOP; }
\<					{ yylval.C = LT; return RELOP; }
\"{IntString}\" 	{ yylval.S = strdup(yytext); return STRING; }
{Delim}+			{ }	/* l'option --yylineno permet de gerer directement le
						 * decompte des sauts de lignes via la variable yylineno.
						 * Il n'y a donc rien de special a faire.
						 */
{Comment}			{ }
.					printf("Caractere errone: %c\n", yytext[0]);
%%

